﻿using NPoco;
using SrBBSPro.BaseClasses;
using System.Collections.Generic;

namespace SrBBSPro.Entities
{   
    /// <summary>
    /// 障害实体
    /// </summary>
    [TableName("Bug")]
    [PrimaryKey("Id,No", AutoIncrement = false)]
    public class Bug : BaseDoubleEntity
    {
        /// <summary>
        /// 机能ID
        /// </summary>
        public string PageId { get; set; }
        /// <summary>
        /// 机能名
        /// </summary>
        public string PageName { get; set; }
        /// <summary>
        /// 操作内容
        /// </summary>
        public string Operation { get; set; }

        /// <summary>
        /// 发生现象
        /// </summary>
        public string Happening { get; set; }

        /// <summary>
        /// 本来式样
        /// </summary>
        public string Original { get; set; }
        /// <summary>
        /// 发生日
        /// </summary>
        public string HappenDay { get; set; }
        /// <summary>
        /// 发行者
        /// </summary>
        public string Issuer { get; set; }
        /// <summary>
        /// 发行者名
        /// </summary>
        public string IssuerName { get; set; }
        
        /// <summary>
        /// 优先级 编号
        /// </summary>
        public string Priority { get; set; }
        /// <summary>
        /// 优先级
        /// </summary>
        [Ignore]
        public string PriorityName
        {
            get => Priority=="0"? "普通": "至急";
        }
        /// <summary>
        /// 预定完了日
        /// </summary>
        public string BookEndDate { get; set; }
        /// <summary>
        /// 确认日
        /// </summary>
        public string ConfirmDay { get; set; }
        /// <summary>
        /// 确认者
        /// </summary>
        public string ConfirmUser { get; set; }
        /// <summary>
        /// 确认者名
        /// </summary>
        public string ConfirmUserName { get; set; }       
        /// <summary>
        /// 现象区分 编号
        /// </summary>
        public string SceneKind { get; set; }
        /// <summary>
        /// 现象区分
        /// </summary>
        [Ignore]
        public string SceneKindName
        {
            get => SceneKind==null?"":SceneKindDic[SceneKind];
           
        }
        /// <summary>
        /// 原因区分(小)编号
        /// </summary>
        public string ReasonSmall { get; set; }
        /// <summary>
        /// 原因区分(小)
        /// </summary>
        [Ignore]
        public string ReasonSmallName
        {
            get => ReasonSmall==null?"": ReasonSmallDic [ReasonSmall];
        }
        /// <summary>
        /// 障害区分 编号
        /// </summary>
        public string BugKind { get; set; }
        /// <summary>
        /// 障害区分
        /// </summary>
        [Ignore]
        public string BugKindName
        {
            get => BugKind==null?"": BugKindDic[BugKind];
        }
        /// <summary>
        /// 修正文件
        /// </summary>
        public string ReviseFile { get; set; }

        /// <summary>
        /// 修正后
        /// </summary>
        public string ReviseAft { get; set; }

        /// <summary>
        /// 修正前
        /// </summary>
        public string ReviseBef { get; set; }
        /// <summary>
        /// 修正者
        /// </summary>
        public string ReviseUser { get; set; }
        /// <summary>
        /// 修正者名
        /// </summary>
        public string ReviseUserName { get; set; }       
        /// <summary>
        /// 修正日
        /// </summary>
        public string ReviseDay { get; set; }

        /// <summary>
        /// 原因区分(大)编号
        /// </summary>
        public string ReasonBig { get; set; }

        /// <summary>
        /// 原因区分(大)
        /// </summary>
        [Ignore]
        public string ReasonBigName
        {
            get => ReasonBig==null?"": ReasonBigDic[ReasonBig];
        }
        /// <summary>
        /// 承认者
        /// </summary>
        public string AcceptUser { get; set; }

        /// <summary>
        /// 承认者名
        /// </summary>
        public string AcceptUserName { get; set; }

        /// <summary>
        /// 是否展开
        /// </summary>
        public string IsUnfold { get; set; } = "0";

        [Ignore]
        public string IsUnfoldName
        {
            get => IsUnfold == "0" ? "否" : "是";
        }

        /// <summary>
        /// 展开番号
        /// </summary>
        public string UnfoldNo { get; set; }

        /// <summary>
        /// 障害状态
        /// </summary>
        public string Status { get; set; }

        /// <summary>
        /// 状态名称
        /// </summary>
        [Ignore]
        public string StatusName
        {
            get => Status==null?"": BugStatus[Status];
        }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 附件
        /// </summary>
        public string Annex { get; set; }

        [Ignore]
        public Dictionary<string, string> ReasonSmallDic = new Dictionary<string, string>()
        {
            {"0","三方插件相关"},
            {"1","Sql错误"},
            {"2","参数不足"},
            {"3","参数设定错误"},
            {"4","共通引用关联"},
            {"5","既存障害"},
            {"6","文件不足"},
            {"7","差异"},
            {"8","指摘错误"},
            {"9","移行不足"},
            {"10","其他"},
            {"11","既存理解错误"},
            {"12","单纯错误"},
            {"13","控件变换错误"},
            {"14","画面刷新错误"},
            {"15","空指针判断错误"},
            {"16","控件属性错误"},
            {"17","页面迁移错误"},
            {"18","事件冲突"},
            {"19","异常处理不足"},
            {"20","SQL排序错误"}
        };

        [Ignore]
        public Dictionary<string, string> SceneKindDic = new Dictionary<string, string>()
        {
            {"0","页面UI不正确"},
            {"1","页面动作不正确"},
            {"2","输入验证不正确"},
            {"3","DB动作不正确"},
            {"4","文件上传下载不正确"},
            {"5","报表内容格式不正确"},
            {"6","性能问题"},
            {"7","系统障害"},
            {"8","操作不正确"},
            {"9","不能再现"},
            {"10","画面初期不正确"},
            {"11","数据表示不正确"},
            {"12","页面迁移不正确"}
        };

        [Ignore]
        public Dictionary<string, string> BugKindDic = new Dictionary<string, string>()
        {
            {"0","不是障害"},
            {"1","移行障害"},
            {"2","既存障害"},
        };

        [Ignore]
        public  Dictionary<string, string> ReasonBigDic = new Dictionary<string, string>()
        {
            {"0","移行方针不足"},
            {"1","自动变换错误"},
            {"2","既存问题"},
            {"3","手动修正错误"},
            {"4","降级"},
            {"5","环境设置错误"},
            {"6","测试式样书错误"},
            {"7","数据异常"},
            {"8","测试工具不足"},
            {"9","指摘错误"},
            {"10","其他"},
            {"11","差异"},
            {"12","数据库问题"},
            {"13","手动修正不足"},
            {"14","控件移行不足"},
            {"15","控件修正不足"},
            {"16","页面刷新考虑不足"},
            {"17","既存理解不足"},
            {"18","事务错误"}
        };

        [Ignore]
        private Dictionary<string, string> BugStatus = new Dictionary<string, string>()
        {
            {"0","起案"},
            {"1","已修正"},
            {"2","修正不足"},
            {"3","已确认"},
            {"4","完了"}
        };
    }
}